Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser: Fix handling of syntax errors such as x =- 2 #7399

Merged
merged 5 commits into from
Jul 27, 2023
Merged

Conversation

kazcw
Copy link
Contributor

@kazcw kazcw commented Jul 25, 2023

Pull Request Description

Most sequences of operator characters are lexed as a single operator; however, there is a special case when the last character is - in order to accept expressions such as x+-1 and x=-1, which use a binary operator followed by a unary operator, in an unspaced subexpression.

Due to this lexical special case, special handling is needed in the parser to reject some related invalid syntaxes, such as x +- 1 and x =- 1. This special handling was absent, resulting in reaching a debug assertion when such syntax errors were encountered (#7335). This PR corrects the assumption in parts of the parser that multiple consecutive operators cannot occur in unspaced subexpressions. See the newly-added test cases for examples of the rejected expressions.

Important Notes

  • Note to QA tester: I have tested that, for every .enso file in the repo, this PR does not change the parser's AST. If there are any regressions, they would relate to inputs that are poor style or syntax errors, both of which are not as thoroughly covered by .enso tests and library files.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@kazcw kazcw self-assigned this Jul 25, 2023
@kazcw kazcw linked an issue Jul 25, 2023 that may be closed by this pull request
@kazcw kazcw marked this pull request as ready for review July 25, 2023 17:28
@kazcw kazcw requested a review from JaroslavTulach as a code owner July 25, 2023 17:28
@kazcw kazcw added the CI: No changelog needed Do not require a changelog entry for this PR. label Jul 25, 2023
@kazcw kazcw marked this pull request as draft July 26, 2023 05:25
@kazcw kazcw marked this pull request as ready for review July 26, 2023 13:53
@kazcw kazcw merged commit 7a934ca into develop Jul 27, 2023
@kazcw kazcw deleted the wip/kw/fix-7335 branch July 27, 2023 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Engine fatal crash when adding a simple node
2 participants